import { UserDao } from "./account_server/dao/UserDao";
import { ClubConfig } from "./hall_server/config/ClubConfig";

import { Config } from "./src/config/Config";
import { DbConfig } from "./src/config/DbConfig";
import { Base64Helper } from "./src/engine/utils/Base64Helper";
import DateUtil from "./src/engine/utils/DateUtil";
import { Logger } from "./src/engine/utils/Logger";
import { MysqlClient } from "./src/engine/utils/MySqlClient";
import { MysqlManager } from "./src/engine/utils/MysqlManager";
import { TimerUtil } from "./src/engine/utils/TimerUtil";
import { MjHuTypeModel } from "./src/model/MjHuTypeModel";
import { MjPrefab } from "./src/model/MjPrefab";
import { MjWeaveItem } from "./src/model/MjWeaveItem";

// require("reflect-metadata")
import "reflect-metadata";
import { DataSource, DBRef, Repository } from "typeorm";
import { DBSourceManager } from "./src/engine/utils/DBSourceManager";
import { AccountEntity } from "./account_server/entity/AccountEntity";
import { AccountDao } from "./account_server/dao/AccountDao";
import { GameConfig } from "./src/config/GameConfig";
import { IdentifiUtil } from "./src/engine/utils/IdentifiUtil";
import { UserEntity } from "./account_server/entity/UserEntity";
import { ClubEntity } from "./hall_server/entity/ClubEntity";
import { ClubDao } from "./hall_server/dao/ClubDao";

export class Test {


    public static instance: Test = new Test()

    public async main() {
        let port: number = parseInt(process.argv[2]);
        if (isNaN(port)) {
            Logger.error("port为空")
            return;
        }

        let environment: number = parseInt(process.argv[3]);
        if (isNaN(port)) {
            Logger.warn("environment为空")
            return;
        }
        Config.environment = environment;
        if (Config.environment == Config.EnvironmentType.Online) {
            Logger.LEVEL = Logger.LOG_LEVEL_TYPES.LOG;
        } else {
            Logger.LEVEL = Logger.LOG_LEVEL_TYPES.DEBUG
        }
        Config.serverType = Config.ServerType_List.log_server;
        Logger.tag = Config.serverType + "-" + port
        // DbConfig.init(DbConfig.Db_Type.Dev)
        DbConfig.init(DbConfig.Db_Type.Dev)
        TimerUtil.init();
        // await ServerConfig.initConfig(port)


        // let user: UserEntity = new UserEntity()
        // user.account = "edddd"
        // let account: AccountEntity = new AccountEntity()
        // account.account = "ABCD✋ ✌ ☝ ✊ ✍ * ⛷ ⛹"
        // account.bundle_name = 'com.jhao.test'
        // account.create_time = DateUtil.formatDateStr(DateUtil.now())
        // let account2:AccountEntity = new AccountEntity()
        // account2.account = "abcd1"
        // await AccountDao.update_account(account)

        // let clubEntity:ClubEntity = new ClubEntity()
        // clubEntity.club_name = "abcd"
        // clubEntity.club_state = ClubConfig.Club_State_Type.Normal
        // clubEntity.clubid = 954146
        // clubEntity.create_time = DateUtil.formatDateStr(DateUtil.now())
        // clubEntity.creator = 124
        // clubEntity.notice = "aerer"
        // ClubDao.create_club(clubEntity)

        AccountDao.get_account_info("swjlrlere")

        // await AccountDao.update_account(account2)
    //     let dataSource: DataSource = await DBSourceManager.instance.getDb(DbConfig.Db_Name.db_account);
    //    let accountRepository:Repository<AccountEntity> = dataSource.getRepository(AccountEntity)
    //    await accountRepository.save(account)
    //     // let fddd = await client.manager.find(AccountEntity)
    //     let fddd = await accountRepository.find()

        // photoRepository.remove()

        // Logger.log("fddd=====", fddd)
        // AccountDao.is_account_exist("ABCD")

        // AppDataSource.initialize().then(async () => {
        //     let dfdf = await AppDataSource.manager.save(user)
        //     Logger.log("save====",dfdf )
        //     // here you can start to work with your database
        // })
        //     .catch((error) => console.log(error))

        // UserDao.create_user("adfdfd", "* ✋ ✌ ☝ ✊ ✍ * ⛷ ⛹", 1, "http://132", "192.168.1.1")
        // UserDao.create_user("adfdfd", " ✋ ¥🔒", 1, "http://132", "192.168.1.1")
        // UserDao.create_user("adfdfd", "¥", 1, "http://132", "192.168.1.1")
        // UserDao.create_user("adfdfd", "🔒", 1, "http://132", "192.168.1.1")

        // AccountDao.is_ip_exist("192.168.1.1")

        // AccountDao.getAccountNum()

        // AccountDao.get_account_list(1, 10)

        // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("🤡🤡")
        // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("✊")
        // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("✌✌✌")
        // Logger.log("isEmojiCharacter=isEmoji=", isEmoji)

        // UserDao.
        // let result = await UserDao.get_user_data_by_account("adfdfd")
        // Logger.log("get_user_data_by_account==", result)

        // let user:UserEntity = new UserEntity()
        // user.userid = 100002
        // user.userid = null
        // user.account = "abcdeffg"
        // user.create_time = DateUtil.formatDateStr(DateUtil.now())
        // UserDao.update_user(user)
    }





}



Test.instance.main()